package cn.iocoder.yudao.module.system.controller.admin.otherService;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.controller.admin.otherService.vo.ApiCallCount;
import cn.iocoder.yudao.module.system.controller.admin.otherService.vo.EtlStatusVO;
import cn.iocoder.yudao.module.system.job.OrganizationalTask;
import cn.iocoder.yudao.module.system.service.otherService.RecordQuery;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;

/**
 * @Description:
 * @Author: meiwanli
 * @Date: 2025-10-09 16:12
 */
@RestController
@Slf4j
@RequestMapping("/system/record-query")
public class OtherServiceController {

    @Resource
    private RecordQuery recordQuery;

    @GetMapping("/getServiceLog")
    @PermitAll
    @Operation(summary = "获取服务日志")
    public CommonResult<String> getServiceLog(Integer serviceType) {
        log.info("获取服务日志");
        return CommonResult.success(recordQuery.getServiceLog(serviceType));
    }

    @GetMapping("/operationService")
    @PermitAll
    @Operation(summary = "操作服务启停")
    public CommonResult<Boolean> operationService(Integer serviceType, Integer operationType) {
        log.info("操作服务启停");
        return CommonResult.success(recordQuery.operationService(serviceType, operationType));
    }


    @GetMapping("/testDriverInfoConn")
    @PermitAll
    public CommonResult<Boolean> testDriverInfoConn() {
        log.info("测试司机信息查询服务接口连通性");
        return CommonResult.success(recordQuery.testDriverInfoConn());
    }

    @GetMapping("/testVehicleInfoConn")
    @PermitAll
    public CommonResult<Boolean> testVehicleInfoConn() {
        log.info("测试车辆信息查询服务接口连通性");
        return CommonResult.success(recordQuery.testVehicleInfoConn());
    }

    @GetMapping("/testShippingNoteConn")
    @PermitAll
    public CommonResult<Boolean> testShippingNoteConn() {
        log.info("测试运单信息查询服务接口连通性");
        return CommonResult.success(recordQuery.testShippingNoteConn());
    }

    @GetMapping("/testCarRepairInfoConn")
    @PermitAll
    public CommonResult<Boolean> testCarRepairInfoConn() {
        log.info("测试车辆送修信息查询服务接口连通性");
        return CommonResult.success(recordQuery.testCarRepairInfoConn());
    }

    @GetMapping("/getEtlStatus")
    @PermitAll
    public CommonResult<List<EtlStatusVO>> getEtlStatus() {
        log.info("获取ETL服务状态");
        return CommonResult.success(recordQuery.getEtlStatus());
    }

    // 获取接口调用次数
    @GetMapping("/portal/getApiCallCount")
    @PermitAll
    public CommonResult<List<ApiCallCount>> getApiCallCount(Integer dayCount) {
        log.info("获取接口调用次数");
        return CommonResult.success(recordQuery.getApiCallCount(dayCount));
    }


}
